Repository navigation
Keep deleted sessions searchable, read-only - #59
Merged
Merged
Conversation
Claude Code deletes transcripts after 30 days by default, and agsearch dropped its index for a session the moment the file went. The session you come back to for how something was decided is usually older than that, so the one search that mattered found nothing. When a transcript disappears, its indexed text is now kept for 180 days. Only what was said is kept: user and assistant messages, each cut to 2,000 characters. Tool output is two thirds of the index and every search reads the whole index, so keeping it would slow search down month after month. Automation runs are not kept at all. Kept sessions are marked `expired` in the list and in `-n`. They cannot be resumed, so Enter opens them in the pager instead, `read` says what the copy is missing, and ctrl-y copies the read command. A transcript that comes back replaces its copy.
Subagent turns in a kept copy were shown as the main thread, because the copy did not record that it came from an agent-*.jsonl file. It does now. Kept copies outlive the cache, so they carry their own layout version and a copy in an older layout is dropped rather than split wrongly. Fragments left over from an older CACHE_FMT are not saved at all, since their layout is unknown. Enter on an expired row ran $PAGER without a shell, so a pager that is not a bare binary, or a missing one, raised a traceback. It now goes through the shell like ctrl-o does. Only the pager string does; the session id and query are still passed as arguments.
devcodes9
force-pushed
the
feat/keep-expired-sessions
branch
from
September 26, 2026 12:08
39bac6c to
7f327cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Claude Code deletes transcripts after 30 days by default (
cleanupPeriodDays). agsearch dropped its index for a session as soon as the file was gone. So "what did we decide last month?" found nothing, for you or for the agent skill.Raised on anthropics/claude-code#77523.
What changes
When a transcript disappears, agsearch keeps the text it had indexed:
How expired sessions behave:
expired, same place asfork-nexpiredread/ preview--no-resumeagsearch read <id>Nothing is written to
~/.claude. The README explains the tradeoff and still leavescleanupPeriodDaysto the user.Screenshots
Synthetic demo corpus, not real transcripts. The first result's transcript was deleted; the second is its live fork.
TUI: the row is tagged
expired, and the preview says it is read only.Enter on the expired row: opens the saved copy in the pager, with a note on what it is missing.
-n(what the agent skill sees): the same tag, in the title position.Size
On my index, keeping everything would add 44 MB a month. The slim copy is about 7.7 MB for the same sessions, and the 180-day cap bounds it.
Test
tests/test_expired.py(11 tests): searchable after deletion, slimming, automation skipped, read note, row tag, 180-day cutoff, restore, forced rebuild, subagent labels, old layouts dropped.$PAGERthrough the shell like ctrl-o.-n,read,_filter,_previewand_copyall behave as above.rank_sessionsis untouched, so gold recall@1 is unchanged.-ntime on the real index is still ~0.8 s.